<template>
  <a-button type="primary" @click="handleUpload">
    上传视频
  </a-button>
</template>

<script setup lang="ts">
import { reactive, watch } from "vue";
import { useUserStore } from "@/store";

interface PropsInterface {
  categoryIds: number[];
  onUpdate: () => void;
}

const props = defineProps<PropsInterface>();

const userStore = useUserStore();

const uploadStatus = userStore.uploadStatus;

watch(
  () => uploadStatus,
  (val) => {
    if (!val) {
      props.onUpdate();
    }
  }
);

const handleUpload = () => {
    const payload = reactive({
        uploadStatus: true,
        uploadCateIds: props.categoryIds
    })
    userStore.uploadAction(payload)
};
</script>
